Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

simplify eth2_network error handling #5765

Merged
merged 4 commits into from
Jan 19, 2024
Merged

simplify eth2_network error handling #5765

merged 4 commits into from
Jan 19, 2024

Conversation

arnetheduck
Copy link
Member

This PR gets rid of a bunch of redundant exception handling through async raises guarantees.

More can be removed once libp2p gets properly annotated.

Includes nim-eth bump for more accurate timeout handling

This PR gets rid of a bunch of redundant exception handling through
async raises guarantees.

More can be removed once libp2p gets properly annotated.

Includes nim-eth bump for more accurate timeout handling
Copy link

github-actions bot commented Jan 17, 2024

Unit Test Results

         9 files  ±0    1 101 suites  ±0   27m 47s ⏱️ -1s
  4 213 tests ±0    3 866 ✔️ ±0  347 💤 ±0  0 ±0 
16 834 runs  ±0  16 436 ✔️ ±0  398 💤 ±0  0 ±0 

Results for commit a4a08e6. ± Comparison against base commit db7909c.

♻️ This comment has been updated with latest results.

@arnetheduck arnetheduck enabled auto-merge (squash) January 19, 2024 07:32
raise exc
except CatchableError as exc:
# switch.disconnect shouldn't raise
warn "Unexpected error while disconnecting peer",
Copy link
Contributor

@zah zah Jan 19, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't we use warning for more actionable information - we are telling the users that there is something wrong with their setup or that we have observed something wrong happening with the network which may explain poor performance, etc. Here, we seem to be telling them about a potential bug in our implementation or alternatively about a very benign networking issue that should not affect their node in any way.

Previously, this was a trace-level message, perhaps DEBUG is justified, but warning seems too much.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

all these warnings would start showing if libp2p starts raising new unexpected errors - it's a transition measure while libp2p upgrades to chronosv4

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is no benefit in using warn vs debug for these kind of messages. They create a risk that we'll run into an unintended increase in log volume (to potentially dangerous levels depending on the particular issue that triggers the increase).

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

#5822 - warn would increase chances that we notice it - swallowed exceptions have historically been a source of several security issues - anyway, hopefully we can be rid of them completely soon.

raise exc
except CatchableError as exc:
# TODO remove once libp2p supports `raises`
warn "Unknown error when opening stream", exc = exc.msg
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ditto, using warn to report implementation issues.

try:
await noCancel stream.close()
except CatchableError as exc:
warn "Unexpected error while closing notification stream",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ditto

except CancelledError as exc:
raise exc
except CatchableError as exc:
warn "Unexpected error", exc = exc.msg
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ditto

except CancelledError as exc:
raise exc
except CatchableError as exc:
warn "Unexpected error", exc = exc.msg
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ditto

`postSerialization`
`tracing`
let `msgBytes` = getOutput(`outputStream`)
let `msgBytes` =
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This improvement can be applied to the other copies of the p2pProtocol DSL.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it is only useful if the DSL is also upgraded to track exceptions, which is a much larger task involving significant changes to rlpx itself - if/when that is done, it would probably make sense to port this together with other changes


debug "Request manager blob tick",
blobs_count = len(fetches),
succeed = succeed,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why were these properties not considered useful?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

cc @etan-status these changes are part of a blob syncing bugfix

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you are referring to #5766 , I did not touch this file at all.

req: SyncRequest): Future[BeaconBlocksRes] {.async.} =
proc getBlocks[A, B](man: SyncManager[A, B], peer: A,
req: SyncRequest): Future[BeaconBlocksRes] {.
async: (raises: [CancelledError], raw: true).} =
mixin getScore, `==`
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This mixin statement doesn't seem to serve any purpose here.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

indeed, probably reasonable to clean it up in the next round of fixes (mixin wasn't part of the scope of this PR)

req: SyncRequest
): Future[BlobSidecarsRes] {.async.} =
req: SyncRequest): Future[BlobSidecarsRes]
{.async: (raises: [CancelledError], raw: true).} =
mixin getScore, `==`
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ditto (unnecessary mixin)

request = req
return

func combine(acc: seq[Slot], cur: Slot): seq[Slot] =
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would look deeper into this. The code seems to use a very inefficient quadratic algorithm with a ton of unnecessary sequence copies and memory allocations. Leave a TODO comment perhaps.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

#5794 might be an opportunity for this - that said, this PR just removed the unnecessary exception handling, the existing logic wasn't looked at

@arnetheduck arnetheduck merged commit 3ff9b69 into unstable Jan 19, 2024
10 checks passed
@arnetheduck arnetheduck deleted the eh-raises branch January 19, 2024 21:05
tersec added a commit that referenced this pull request Jan 28, 2024
tersec added a commit that referenced this pull request Jan 28, 2024
tersec added a commit that referenced this pull request Jan 29, 2024
tersec added a commit that referenced this pull request Jan 29, 2024
tersec added a commit that referenced this pull request Feb 8, 2024
arnetheduck added a commit that referenced this pull request Feb 9, 2024
* unrevert rest of #5765

* rm stray e2store docs changes

* reduce diff

* fix indent

---------

Co-authored-by: Jacek Sieka <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants